package com.erhuogo.bean;

import java.util.List;

/**
 * 分页用到的Page bean
 * @author aibinxiao
 * @param <T>
 * @date 2016年10月25日 下午2:08:38
 */
public class PageBean<T> {//泛型的使用
	private int pageSize;//  每页显示的记录条数
	private List<T> records;//  每页显示的记录				DAO?
	private int pageNum;//  当前显示的页码				           用户传进来
	private int totalPage;//  总共的页数					计算出来
	
	private int startIndex;// 每页开始记录的索引			          计算出来
	private int totalRecords;// 总记录的条数				DAO
	
	public PageBean(int pageNum, int totalRecords, int pageSize){
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.totalRecords = totalRecords;
		//总共的页数				计算出来
		totalPage = totalRecords%pageSize==0?totalRecords/pageSize:totalRecords/pageSize+1;
		//每页开始记录的索引			计算出来
		startIndex = (pageNum-1)*pageSize;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public List<T> getRecords() {
		return records;
	}

	public void setRecords(List<T> records) {
		this.records = records;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getStartIndex() {
		return startIndex;
	}

	public void setStartIndex(int startIndex) {
		this.startIndex = startIndex;
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}

}
